<html>
<head><meta charset="utf-8"><title>Inference for trait objects · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Inference.20for.20trait.20objects.html">Inference for trait objects</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="195291007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Inference%20for%20trait%20objects/near/195291007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Inference.20for.20trait.20objects.html#195291007">(Apr 25 2020 at 16:05)</a>:</h4>
<p><span class="user-mention" data-user-id="129457">@Florian Diebold</span> I was thinking why not making <code>&amp;dyn Trait</code> behave like <code>&amp;impl Trait</code> at least for the short term. Of course, this is not how it works but I'm just wondering if we can close that gap this way until the proper support is implemented?</p>



<a name="195291053"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Inference%20for%20trait%20objects/near/195291053" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Inference.20for.20trait.20objects.html#195291053">(Apr 25 2020 at 16:06)</a>:</h4>
<p>you mean the other way around?</p>



<a name="195291070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Inference%20for%20trait%20objects/near/195291070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Inference.20for.20trait.20objects.html#195291070">(Apr 25 2020 at 16:07)</a>:</h4>
<p>I don't think it's worth doing, proper <code>impl Trait</code> support in Chalk isn't far off</p>



<a name="195291078"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Inference%20for%20trait%20objects/near/195291078" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Inference.20for.20trait.20objects.html#195291078">(Apr 25 2020 at 16:07)</a>:</h4>
<p>Not sure what you mean by "other way around", <code>impl Trait</code> works fine, while <code>dyn Trait</code> doesn't...</p>



<a name="195291138"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Inference%20for%20trait%20objects/near/195291138" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Inference.20for.20trait.20objects.html#195291138">(Apr 25 2020 at 16:08)</a>:</h4>
<p>This is especially palpable since we switched to <code>dyn</code> for <code>salsa::Database</code></p>



<a name="195291145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Inference%20for%20trait%20objects/near/195291145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Inference.20for.20trait.20objects.html#195291145">(Apr 25 2020 at 16:09)</a>:</h4>
<p>only argument position <code>impl Trait</code> works fine, return position <code>impl Trait</code> doesn't work at all currently</p>



<a name="195291151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Inference%20for%20trait%20objects/near/195291151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Inference.20for.20trait.20objects.html#195291151">(Apr 25 2020 at 16:09)</a>:</h4>
<p>whereas <code>dyn Trait</code> mostly works fine, just is missing super trait support</p>



<a name="195291155"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Inference%20for%20trait%20objects/near/195291155" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Inference.20for.20trait.20objects.html#195291155">(Apr 25 2020 at 16:10)</a>:</h4>
<p>which is something that could just be fixed in Chalk</p>



<a name="195291157"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Inference%20for%20trait%20objects/near/195291157" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Inference.20for.20trait.20objects.html#195291157">(Apr 25 2020 at 16:10)</a>:</h4>
<p>Aha, so this is due to the supertaits...</p>



<a name="195291198"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Inference%20for%20trait%20objects/near/195291198" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Inference.20for.20trait.20objects.html#195291198">(Apr 25 2020 at 16:10)</a>:</h4>
<p>(it's on my list...)</p>



<a name="195291213"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Inference%20for%20trait%20objects/near/195291213" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> std::Veetaha <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Inference.20for.20trait.20objects.html#195291213">(Apr 25 2020 at 16:11)</a>:</h4>
<p>So, this is the chalk field of responsibility and we cannot put a gag in our code.</p>



<a name="195291877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Inference%20for%20trait%20objects/near/195291877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Inference.20for.20trait.20objects.html#195291877">(Apr 25 2020 at 16:27)</a>:</h4>
<p>it would be harder to work around this in our code than in Chalk</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>